<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="java.text.SimpleDateFormat,java.util.Calendar"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	Calendar cal = Calendar.getInstance();
	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
	String today = format.format(cal.getTime());
%>
<!DOCTYPE HTML>
<html>
	<head>
		<base href="<%=basePath%>">
		<META http-equiv=Content-Type content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="stylesheet" href="include/layui/css/layui.css" type="text/css"/>
		<link type="text/css" rel="stylesheet" href="include/layer/skin/default/layer.css"/>
		<script type="text/javascript" src="include/js/jquery-1.7.min.js"></script>
		<script type="text/javascript" src="include/js/bootstrap.js"></script>
		<script type="text/javascript" src="include/layer/layer.js"></script>
		<script type="text/javascript" src="include/layui/layui.js"></script>
	</head>
	<script type="text/javascript">
			layui.use('layedit', function(){
			  	var layedit = layui.layedit;
			  	var index = layedit.build('remarks',{
				  height: 230,//设置编辑器高度
				  tool: [
					  'strong' //加粗
					  ,'italic' //斜体
					  ,'underline' //下划线
					  ,'del' //删除线
					  ,'|' //分割线
					  ,'left' //左对齐
					  ,'center' //居中对齐
					  ,'right' //右对齐
					  ,'|' //分割线
					  ,'link' //超链接
					  ,'unlink' //清除链接
					  ,'face' //表情
					]
				});
			  	
				$('#addRemark').click(function(){
					var aaa = layedit.getContent(index);
					var title1 = $("#title1").val();
					
					if('' == title1)
					{
						layer.tips('请填写日志标题', '#title1', {
						  tips: [3, '#FF3300']
						});
						return;
					}
					if('' == aaa)
					{
						layer.msg('日志内容不能为空',{icon:3});
						return;
					}
					
					layer.confirm('确定录入日志吗？', {
					  btn: ['确定录入','取消录入'],skin: 'layui-layer-lan',shade: [0],closeBtn: false
					}, function(){
						$.ajax({
						type: "POST",
						data:{"titles":title1,"contents":aaa},
						url: "RemarkAction/addRemark.action",
						dataType: "json",
						success: function(res)
						{
							if(res.result)
							{
								parent.test('saveRemark');
								
		                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		                        parent.layer.close(index);
							}
							else
							{
								layer.msg('备忘录入失败，请联系作者！', {icon: 2});
							}
						}
					});
					}, function(){
					  layer.msg('已取消', {icon: 2});
					});
				  });
			});
			
	</script>
	<body>
				<div class="layui-form-item" style="padding-top: 10px;margin-left: -10px;">
		          <label class="layui-form-label">备忘标题：</label>
		          <div class="layui-input-inline">
		            <input type="text" name="title1" id="title1" placeholder="请输入备忘录标题" 
		            					style="width:560px;" class="layui-input">
		          </div>
		        </div>
			<div class="row cl">
				<textarea id="remarks" style="display: none;"></textarea>
			</div><br/>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					 <button class="layui-btn" id="addRemark" style="margin-left:280px;">立即提交</button>
				</div>
			</div>
	</body>
</html>